package activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.coolweather.lechat.MainActivity;
import com.coolweather.lechat.R;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;

public class login extends AppCompatActivity {
    private EditText log_username,log_password;
    private Button log_button,log_reg_button;
    public String userId = "xiaozhufeifei";
    public String TAG="login";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        initView();
        log_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                V2TIMManager.getInstance().login(userId, GenerateTestUserSig.genTestUserSig(userId), new V2TIMCallback() {
                    @Override
                    public void onSuccess() {
                        Intent intent = new Intent(login.this, MainActivity.class);
                        startActivity(intent);
                        Log.e(TAG, "onSuccess:1111111111111111111111111111");
                    }

                    @Override
                    public void onError(int code, String desc) {
                        Log.e(TAG, "onError:2222222222222222222"+code+desc);
                    }
                });
            }
        });
        log_username.setText(getIntent().getStringExtra("user"));
        log_password.setText(getIntent().getStringExtra("pass"));

    }

    private void initView() {
        log_username = findViewById(R.id.log_username);
        log_password = findViewById(R.id.log_password);
        log_button = findViewById(R.id.log_button);
        log_reg_button = findViewById(R.id.log_reg_button);
    }
}